package me.model;

import me.Adventure.Adventure;
import me.enums.Directions;

import org.newdawn.slick.geom.Rectangle;

public class Hero {
	
	private Rectangle square;
	private AdventureItem item;
	private final float SPEED = 0.4f;
	
	public Hero(int x, int y){
		square = new Rectangle(x, y, Adventure.squareWidth, Adventure.squareHeight);
	}

	public float getX() {
		return square.getX();
	}

	public void setX(float x) {
		square.setX(x);
	}

	public float getY() {
		return square.getY();
	}

	public void setY(float y) {
		square.setY(y);
	}

	public Rectangle getSquare() {
		return square;
	}

	public void setSquare(float x, float y) {
		square.setX(x);
		square.setY(y);
	}
	
	public AdventureItem getItem() {
		return item;
	}

	public void setItem(AdventureItem item) {
		this.item = item;
	}
		
	public void move(Directions dir){
		
		float x = getX();
		float y = getY();
		
		switch(dir){
			case UP:{
				y-=SPEED;
				setY(y);
				break;
			}
		
			case DOWN:{
				y+=SPEED;
				setY(y);
				break;
			}
			
			case LEFT:{
				x-=SPEED;
				setX(x);
				break;
			}
			
			case RIGHT:{
				x+=SPEED;
				setX(x);
				break;
			}
		}
		
		if(this.getItem()!=null){
			moveItem(getItem());
		}
		
	}
	
	public void pickItem(AdventureItem item, Directions dir){
		
		final int PULL = 20;
		
		switch (dir){
			case UP:{
				item.setY(item.getY() + PULL);
			}
			
			case DOWN:{
				item.setY(item.getY() - PULL);				
			}
			
			case LEFT:{
				item.setX(item.getX() - PULL);
			}
			
			case RIGHT:{
				item.setX(item.getX() + PULL);				
			}
		}
		
		setItem(item);
		
	}
	
	public void dropItem(){
		setItem(null);
	}
	
	private void moveItem(AdventureItem item){
		
	}
	
}
